package cn.lyjuan.payment.third.base.pay.chl.impl.weixin.util;

import cn.lyjuan.base.util.EnumUtils;

/**
 * 微信交易类型
 * Created by chad on 2017/1/16.
 */
public enum TradeTypeEnum
{
    /**
     * 公众号支付
     */
    JSAPI,

    /**
     * 原生扫码支付
     */
    NATIVE,

    /**
     * app支付
     */
    APP;

    public static TradeTypeEnum from(Object tradeTypeEnum)
    {
        if (isJsapi(tradeTypeEnum))
            return JSAPI;
        if (isNative(tradeTypeEnum))
            return NATIVE;
        if (isApp(tradeTypeEnum))
            return APP;

        return null;
    }

    public static boolean isJsapi(Object tradeTypeEnum)
    {
        return EnumUtils.equals(JSAPI, tradeTypeEnum);
    }

    public static boolean isNative(Object tradeTypeEnum)
    {
        return EnumUtils.equals(NATIVE, tradeTypeEnum);
    }

    public static boolean isApp(Object tradeTypeEnum)
    {
        return EnumUtils.equals(APP, tradeTypeEnum);
    }
}
